<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/common.jsp" %>
<%
	String path = request.getContextPath();
	if (path.equals("/")) {
		path = "";
	}
	pageContext.setAttribute("path", path);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${path}/css/manage_center.css"/> 
<script type="text/javascript" src="${path}/js/jquery/jquery-1.5.1.js"></script>
<script type="text/javascript" src="${path}/js/jquery/jquery.corner.js"></script>
<script type="text/javascript" src="${path}/js/common.js"></script>
<title>QQ管理</title>

<script type="text/javascript">

//query同步get请求	
$.ajaxSetup({   
	async : false  
});

//删除公共部分
function delPublic(ids) {
	var url = "${path}/adminmgr/qq_delQQById?ids="+ids;
	$.get(url,null,function(data){
		if(data == "success") {
			alert("删除成功");
			window.location.reload(true);			
		} else {
			alert("存在子条目不允许删除");
		}
	}, "text");
}

//批量删除
function delQQ() {
	var checkboxs = document.getElementsByName("boxIds");
	var falg = false;
	for ( var i = 0; i < checkboxs.length; i++) {
		if (checkboxs[i].checked) {
			falg = true;
		}
	}
	if (!falg) {
		alert("请选择数据!");
		return false;
	} else {
		if(confirm("确定删除吗?")){
			delId = "";
			for ( var i = 0; i < checkboxs.length; i++) {
				if (checkboxs[i].checked) {
					delId += checkboxs[i].value + "|";
				}
			}
			delPublic(delId);
		}
	}
}

//根据id删除
function delById(id) {
	if(id == null || id == "") {
		alert("请选择数据");
	} else {
		if(confirm("确定删除吗?")){
			delPublic(id);
		}
	}
	
}

//添加
function openAdd() {
	window.location.href = "${path}/adminmgr/qq_openAddOrUpdate";
}

//编辑
function openUpdate(qqId) {
	window.location.href = "${path}/adminmgr/qq_openAddOrUpdate?qqId=" + qqId;
}

</script>

<style type="text/css">
	table .td_link a {
	    color: #0000FF;
	}
</style>
</head>

	<body>
	
		<div id="right0">
       <table class="all_table" border="0">
                <tr class="tops" style="background: #DCD9D3;">
                    <td>         
                    		<ul>	
		                        <li>
									<table style="margin-left: 850;"><tr><td>
		                        		<input type="button" value="添加" onclick="openAdd()"/>
		                        		<input type="button" value="选中删除" onclick="delQQ()"/>
		                        	</td></tr></table>
								</li>
	                        </ul>           
                    </td>
                </tr>
                <tr valign="top">
                    <td>  
                            <div class="content2" style="margin-top: 0px;">
					            <table id="tablea" class="tablea" style="margin-left: 5px;">
					                <tbody>
					                    <tr class="tr3">
					                        <th width="25"><input type="checkbox" name="checkbox"
					                            onclick="changeAll(this.checked)" />
					                        </th>
					                        <th>QQ号</th>
					                        <th>名称</th>
					                        <th>创建时间</th>                     
					                        <th>更新时间</th>                     
					                        <th>操作着</th>                      
					                        <th width="140">其他操作</th>
					                    </tr>
					                    <s:iterator value="#request.qqList" status="stat">
					                        <tr class="tr<s:property value='#stat.index%2+1' />" >
					                            <td style="line-height: 33px;height:33px;"><input type="checkbox" name="boxIds"
					                                value="<s:property value="id" />" />
					                            </td>
					                            <td><s:property value="qq" /></td>
					                            <td><s:property value="name" /></td>
					                            <td><s:date name="createTime" format="yyyy-MM-dd HH:mm:ss"/></td>
					                            <td><s:date name="updateTime" format="yyyy-MM-dd HH:mm:ss"/></td>
					                            <td><s:property value="operator.name" /></td>
					                            
					                            <td width="140" class="td_link">
					                            	<a href="javascript::" onclick="openUpdate('<s:property value="id" />')">编辑</a> 
					                            	<a href="javascript::" onclick="delById('<s:property value="id" />')">删除</a>
					                            </td>
					                        </tr>
					                    </s:iterator>
					                </tbody>
					            </table>
					        </div>
                    </td>
                </tr>
                <tr>
                </tr>
            </table>
		<div class="clear"></div>
	</div>
	
		<script type="text/javascript">
	       //变成圆角 
		   becomeCorner('all_table');
	   </script>
	</body>
</html>
